<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Vue</title>
    <link rel="stylesheet" href="/css/common.css">
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script>
</head>
<body>
<div id="app">
    <input placeholder="请输入内容" v-model="myInput"/>
    <div>{{desc}}</div>
</div>
<script type="text/javascript">
    const app = new Vue({
        el: '#app',
        data: {
            myInput: '',
            desc: ''
        }
    })
    app.$watch('myInput', function (newVal, oldVal) {
        console.log('New: ', newVal)
        app.$data.desc = '总共输入' + app.$data.myInput.length + '字'
    })
</script>
</body>
</html>
